package com.cloudlead.customerAction.service.impl.gps.util;

/**
 * Created by Will on 2015/11/24.
 */
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Vector;
import java.util.Map.Entry;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
public class AsmxGps {
    public Object callAsmxWebService(String serviceUrl, String serviceNamespace,
                                     String methodName, Map<String, String> params)
            throws ServiceException, RemoteException, MalformedURLException {
        org.apache.axis.client.Service service = new org.apache.axis.client.Service();
        Call call = (Call) service.createCall();
        call.setTargetEndpointAddress(new java.net.URL(serviceUrl));
        call.setOperationName(new QName(serviceNamespace, methodName));
        ArrayList<String> paramValues = new ArrayList<String>();
        for (Entry<String, String> entry : params.entrySet()) {
            call.addParameter(new QName(serviceNamespace, entry.getKey()),
                    XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
            paramValues.add(entry.getValue());
        }
        call.setUseSOAPAction(true);
        call.setSOAPActionURI(serviceNamespace + methodName);
        call.setReturnType(new QName(serviceNamespace,methodName),Vector.class);
        return (call.invoke(paramValues.toArray()));
    }
}
